- name: d8.control-plane-manager.malfunctioning
  rules:
  - alert: D8ControlPlaneManagerPodNotRunning
    for: 10m
    expr: |
      max by (node) (
        kube_node_role{role="master"}
        unless
        kube_node_role{role="master"}
        * on(node) group_left() (
          (kube_pod_status_ready{condition="true"} == 1)
          * on (pod, namespace) group_right()
          kube_controller_pod{
            controller_type="DaemonSet",
            namespace="kube-system",
            controller_name="d8-control-plane-manager"
          }
        )
      )
    labels:
      d8_component: control-plane-manager
      d8_module: control-plane-manager
      severity_level: "6"
      tier: cluster
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_create_group_if_not_exists__d8_control_plane_manager_unavailable: "D8ControlPlaneManagerUnavailable,tier=cluster,prometheus=deckhouse,kubernetes=~kubernetes"
      plk_grouped_by__d8_control_plane_manager_unavailable: "D8ControlPlaneManagerUnavailable,tier=cluster,prometheus=deckhouse,kubernetes=~kubernetes"
      summary: Controller Pod not running on Node {{ $labels.node }}
      description: |-
        Pod `d8-control-plane-manager` fails or not scheduled on Node {{ $labels.node }}

        Consider checking state of the `kube-system/d8-control-plane-manager` DaemonSet and its Pods:
        `kubectl -n kube-system get daemonset,pod --selector=app=d8-control-plane-manager`

  - alert: D8KubernetesVersionIsDeprecated
    for: 10m
    expr: max by (k8s_version) (d8_kubernetes_version{k8s_version="1.24"}) == 1
    labels:
      severity_level: "7"
      tier: cluster
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      summary: Kubernetes version "{{ $labels.k8s_version }}" is deprecated
      description: |-
        Current kubernetes version "{{ $labels.k8s_version }}" is deprecated, and its support will be removed within 6 months

        Please migrate to the next kubernetes version (at least 1.25)

        Check how to update the Kubernetes version in the cluster here - https://deckhouse.io/documentation/deckhouse-faq.html#how-do-i-upgrade-the-kubernetes-version-in-a-cluster

  - alert: KubernetesVersionEndOfLife
    for: 10m
    expr: max by (k8s_version) (d8_kubernetes_version{k8s_version="1.23"}) == 1
    labels:
      severity_level: "4"
      tier: cluster
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      summary: Kubernetes version "{{ $labels.k8s_version }}" has reached End Of Life.
      description: |-
        Current kubernetes version "{{ $labels.k8s_version }}" support will be removed in the next Deckhouse release (1.58).

        Please migrate to the next kubernetes version (at least 1.24) as soon as possible.

        Check how to update the Kubernetes version in the cluster here - https://deckhouse.io/documentation/deckhouse-faq.html#how-do-i-upgrade-the-kubernetes-version-in-a-cluster
